import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by iss on 17/6/2.
 */
public class NettyTestUtil {

    public static Map<String, ChannelHandlerContext> pool = new HashMap<String, ChannelHandlerContext>();


    public static ByteBuf encodeString(String s) {
        byte[] b;
        ByteBuf byteBuf = null;
        try {
            b = s.getBytes("utf-8");
            byteBuf = ByteBufAllocator.DEFAULT.buffer(b.length);
            byteBuf.writeBytes(b);

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return byteBuf;
    }
}
